/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package cn.powertalk3.server.service;

import cn.powertalk3.server.DAO.UserDAO;
import cn.powertalk3.server.model.User;

/**
 *
 * @author mrgaolei
 */
public class UserService extends BaseService {
	private UserDAO userDAO;

	public UserService() {
		this.userDAO = new UserDAO();
	}

	/**
	 * 注册
	 * @param user
	 */
	public void register(User user) {
		this.userDAO.save(user);
	}

	/**
	 * 登录
	 * @param email
	 * @param password
	 * @return
	 */
	public int login(String email, String password) {
        User user = this.userDAO.getUserByEmail(email);
        if (password.equals(user.getPassword())) {
            return 1;
        }
		return 0;
	}
}
